package com.sls.web.manager.action.game;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;

import com.sls.web.manager.action.SuperAction;
import com.sls.web.manager.execption.ManagerException;
import com.sls.web.manager.game.pojo.SnnsOrderBalanceInfo;
import com.sls.web.manager.game.querybean.SnnsOrderBalanceQuery;
import com.sls.web.manager.game.service.SnnsOrderBalanceService;

/**
 * 
 * @description 7996余额查询
 * @author Wangxuegang
 * @date 2013-4-24
 */
public class SnnsBalanceAction extends SuperAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private SnnsOrderBalanceQuery snnsOrderBalanceQuery;

	private List<SnnsOrderBalanceInfo> supUserIdList;

	private SnnsOrderBalanceInfo snnsOrderBalanceInfo;

	@Resource(name = "snnsOrderBalanceService")
	private SnnsOrderBalanceService snnsOrderBalanceService;

	/**
	 * 账户余额
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryBalance() throws Exception {
		try {
			supUserIdList = snnsOrderBalanceService.querySupUserId(
					snnsOrderBalanceInfo, getCurrentOperator());
			String supUserId = snnsOrderBalanceQuery.getCid();
			if (StringUtils.isNotEmpty(supUserId)) {
				supUserId = supUserId.trim();
			}
			snnsOrderBalanceQuery.setCid(supUserId);
			snnsOrderBalanceInfo = snnsOrderBalanceService.querySnnsBalance(
					snnsOrderBalanceQuery, getCurrentOperator());
			if (!snnsOrderBalanceInfo.isBalanceResult()) {
				flag = false;
				addActionMessage(snnsOrderBalanceInfo.getBalance());
			} else {
				return "balance";
			}
		} catch (ManagerException e) {
			flag = false;
			addActionError(e.getMessage());
		}
		return "balance";
	}

	// -----------------------

	public SnnsOrderBalanceQuery getSnnsOrderBalanceQuery() {
		return snnsOrderBalanceQuery;
	}

	public void setSnnsOrderBalanceQuery(
			SnnsOrderBalanceQuery snnsOrderBalanceQuery) {
		this.snnsOrderBalanceQuery = snnsOrderBalanceQuery;
	}

	public List<SnnsOrderBalanceInfo> getSupUserIdList() {
		return supUserIdList;
	}

	public void setSupUserIdList(List<SnnsOrderBalanceInfo> supUserIdList) {
		this.supUserIdList = supUserIdList;
	}

	public SnnsOrderBalanceInfo getSnnsOrderBalanceInfo() {
		return snnsOrderBalanceInfo;
	}

	public void setSnnsOrderBalanceInfo(
			SnnsOrderBalanceInfo snnsOrderBalanceInfo) {
		this.snnsOrderBalanceInfo = snnsOrderBalanceInfo;
	}

}
